import urllib.request, sys
import ssl


host = 'https://tysbgpu.market.alicloudapi.com'
path = '/api/predict/ocr_general'
method = 'POST'
appcode = 'f6ba36b080144a3c9775f2f5dced3b76'
querys = ''
bodys = {}
url = host + path

bodys[''] = "{\"image\":\"/Users/liuchong/learning-notes/AliOCR/resources/IMG_0560.jpeg\",\"configure\":{\"output_prob\":true,\"output_keypoints\":false,\"skip_detection\":false,\"without_predicting_direction\":false}}"
post_data = bodys['']
print(post_data)
request = urllib.request.Request(url, post_data)
request.add_header('Authorization', 'APPCODE ' + appcode)
# 根据API的要求，定义相对应的Content-Type
request.add_header('Content-Type', 'application/json; charset=UTF-8')
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
response = urllib.request.urlopen(request, context=ctx)
content = response.read()
if (content):
    print(content)